package com.cskaoyan.gateway.controller.shopping;

import com.mall.commons.result.ResponseData;
import com.mall.commons.result.ResponseUtil;
import com.mall.order.CancelOrderService;
import com.mall.order.dto.CancelOrderResponse;
import com.mall.order.dto.PostCancelOlderRequest;
import com.mall.shopping.IContentService;
import com.mall.shopping.IHomeService;
import com.mall.shopping.constants.ShoppingRetCode;
import com.mall.shopping.dto.HomePageResponse;
import com.mall.shopping.dto.NavListResponse;
import com.mall.user.annotation.Anoymous;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;

/**
 * @Author : PengFei Zhang
 * @Data :2021/6/17  23:36
 * @Description :
 */
@RestController
@RequestMapping("/shopping")
public class ShoppingOfController {

    @Reference(interfaceClass = IHomeService.class, timeout = 3000, retries = 0, check = false)
    IHomeService iHomeService;

    @Reference(interfaceClass = IContentService.class, timeout = 3000, retries = 0, check = false)
    IContentService iContentService;



    //主页  zpf
    @GetMapping("homepage")
    @Anoymous
    public ResponseData getHomepage() {
        //获取首页信息
        HomePageResponse response = iHomeService.homepage();
        if (ShoppingRetCode.SUCCESS.getCode().equals(response.getCode())) {
            return new ResponseUtil().setData(response.getPanelContentItemDtos());
        }
        return new ResponseUtil().setErrorMsg(response.getMsg());
    }

    //导航栏  zpf
    @GetMapping("navigation")
    @Anoymous
    public ResponseData getNavigation() {
        NavListResponse response = iContentService.queryNavList();
        if (ShoppingRetCode.SUCCESS.getCode().equals(response.getCode())) {
            return new ResponseUtil().setData(response.getPannelContentDtos());
        }
        return new ResponseUtil().setErrorMsg(response.getMsg());
    }



}
